package com.ysd.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ysd.dao.impl.XiangQingDaoImpl;
import com.ysd.dao.impl.XiangQingErDaoImpl;
import com.ysd.dao.impl.ZiXunDaoImpl;
import com.ysd.entity.XiangQing;
import com.ysd.entity.ZiXun;

public class NewsServlet extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
		ZiXunDaoImpl xinwen = new ZiXunDaoImpl();
		List<ZiXun> list = xinwen.getZiXunList();
		request.setAttribute("list", list);

		// 根据资讯详情id查询新闻资讯
		// 接受前台传来的参数 zXFenLeiId
		int cId = Integer.parseInt(request.getParameter("zXFenLeiId"));
		XiangQingErDaoImpl xd = new XiangQingErDaoImpl();
		List<XiangQing> xiangqingList = xd.getXiangQingErsList(cId);
		request.setAttribute("xiangqingList", xiangqingList);// 忘记存了吧, 剩下来的自己写吧, 总体写的不错~ 基本有结果了

		request.getRequestDispatcher("article_list.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}

}
